class Tile {
  float radius;
  float xpos, ypos;
  float type;
  Texture tex;

  void init(float x, float y, int type) {
    this.radius = height/5/2;
    this.xpos = (float)x;
    this.ypos = (float)y;
    this.type = type;
    try{
      switch(type) {
      case 1: 
        tex = TextureIO.newTexture(new File(dataPath("forest.jpg")),true); 
        break;
      case 2: 
        tex = TextureIO.newTexture(new File(dataPath("brick.jpg")),true); 
        break;
      case 3: 
        tex = TextureIO.newTexture(new File(dataPath("wool.jpg")),true); 
        break;
      case 4: 
        tex = TextureIO.newTexture(new File(dataPath("wheat.jpg")),true); 
        break;
      case 5: 
        tex = TextureIO.newTexture(new File(dataPath("wheat.jpg")),true); 
        break;
      case 6: 
        tex = TextureIO.newTexture(new File(dataPath("ore.jpg")),true); 
        break;
      case 7: 
        println("Wireframe Tile (ID 7) Created");
        tex = TextureIO.newTexture(new File(dataPath("white.png")),true);
        break;
      default: 
        println("Unrecognized Texture ID Value ("+type+"): Must be between 1 and 6");
      }
    } 
    catch (Exception e) { 
      println(e); 
    }
  }

  void update() {

  }  

  void move(int x, int y) {
    this.xpos = x;
    this.ypos = y;
  }

  void move(float x, float y) {
    this.xpos = x;
    this.ypos = y;
  }

  void drawOldSchool(GL gl) {
    gl.glBegin(GL.GL_POLYGON);
    gl.glTexCoord2f((xpos-radius)/width,ypos/height); 
    gl.glVertex2f(xpos-radius,ypos);
    gl.glTexCoord2f((xpos-(radius/2))/width,(ypos-radius)/height); 
    gl.glVertex2f(xpos-(radius/2),ypos-radius);
    gl.glTexCoord2f((xpos+(radius/2))/width,(ypos-radius)/height); 
    gl.glVertex2f(xpos+(radius/2),ypos-radius);
    gl.glTexCoord2f((xpos+radius)/width,ypos/height); 
    gl.glVertex2f(xpos+radius,ypos);
    gl.glTexCoord2f((xpos+(radius/2))/width,(ypos+radius)/height); 
    gl.glVertex2f(xpos+(radius/2),ypos+radius);
    gl.glTexCoord2f((xpos-(radius/2))/width,(ypos+radius)/height); 
    gl.glVertex2f(xpos-(radius/2),ypos+radius);
  }

  void drawWireframe(GL gl) {
    gl.glBegin(GL.GL_LINES);
    gl.glColor3f(1.0f,1.0f,1.0f);
    gl.glVertex2f(xpos-radius,ypos);
    gl.glVertex2f(xpos-(radius/2),ypos-radius);
    gl.glVertex2f(xpos+(radius/2),ypos-radius);
    gl.glVertex2f(xpos+radius,ypos);
    gl.glVertex2f(xpos+(radius/2),ypos+radius);
    gl.glVertex2f(xpos-(radius/2),ypos+radius);
  }
}




